package com.ityu.controller;

import com.ityu.pojo.result.Result;
import com.ityu.utlis.AliyunOSSOperator;
import com.ityu.utlis.AliyunOSSOperator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RequestMapping
@RestController
public class UploadController {

    @Autowired
    private AliyunOSSOperator aliyunOSSOperator;
    @PostMapping("/upload")
    public Result upload(String name , Integer age , MultipartFile file) throws Exception {
        log.info("-----UploadController-----上传文件!" );
        String URL = aliyunOSSOperator.upload(file.getBytes(), file.getOriginalFilename());
        return Result.success(URL);
    }

}
